package t3dao;

import java.util.List;
import t3bean.MoneyRecordBean;
import t3bean.ParkingRecordBean;
import t3bean.ParkingSpaceBean;

public class SetSql {
	public String setSql(ParkingSpaceBean psb, String sql, List<Object> list, int m) {
		int n = 0;
		if (psb.getSpaceId() != null) {
			if (n == 1) {
				sql += ",";
			} else if (n == 2) {
				sql += " and ";
			}
			sql += "space_id=?";
			list.add(psb.getSpaceId());
			n = m;
		}
		if (psb.getIsParking() != null) {
			if (n == 1) {
				sql += ",";
			} else if (n == 2) {
				sql += " and ";
			}
			sql += "isparking=?";
			list.add(psb.getIsParking());
			n = m;
		}
		if (psb.getCarid() != null) {
			if (n == 1) {
				sql += ",";
			} else if (n == 2) {
				sql += " and ";
			}
			sql += "carid=?";
			list.add(psb.getCarid());
			n = m;
		}
//		System.out.println(sql);
		return sql;
	}

	public String setSql(ParkingRecordBean prb, String sql, List<Object> list, int m) {
		int n = 0;
		if (prb.getCarId() != null) {
			if (n == 1) {
				sql += ",";
			} else if (n == 2) {
				sql += " and ";
			}
			sql += "car_id=?";
			list.add(prb.getCarId());
			n = m;
		}
		if (prb.getParkingTime() != null) {
			if (n == 1) {
				sql += ",";
			} else if (n == 2) {
				sql += " and ";
			}
			sql += "parkingtime=?";
			list.add(prb.getParkingTime());
			n = m;
		}
		if (prb.getSpaceId() != null) {
			if (n == 1) {
				sql += ",";
			} else if (n == 2) {
				sql += " and ";
			}
			sql += "space_id=?";
			list.add(prb.getSpaceId());
			n = m;
		}
		return sql;
	}

	public String setSql(MoneyRecordBean mrb, String sql, List<Object> list, int m) {
		int n = 0;
		if(mrb.getCarId()!=null) {
			if (n == 1) {
				sql += ",";
			} else if (n == 2) {
				sql += " and ";
			}
			sql += "car_id=?";
			list.add(mrb.getCarId());
			n = m;
		}
		if (mrb.getSpaceId() != null) {
			if (n == 1) {
				sql += ",";
			} else if (n == 2) {
				sql += " and ";
			}
			sql += "space_id=?";
			list.add(mrb.getSpaceId());
			n = m;
		}
		if (mrb.getMoney() != null) {
			if (n == 1) {
				sql += ",";
			} else if (n == 2) {
				sql += " and ";
			}
			sql += "money=?";
			list.add(mrb.getMoney());
			n = m;
		}
		return sql;
	}
}
